import request from '@/utils/request'

export type UserFollowVO = {
	// 自增ID
	id : number;
	// 被关注用户ID
	followedUserId : number;
	// 被关注用户名称
	followedUserName : string;
	// 被关注用户头像
	followedUserAvatar : string
	// 粉丝ID
	fansId : number;
	// 粉丝名称
	fansName : string;
	// 粉丝头像
	fansAvatar : string
	// 关注时间
	followTime : Date;
}

export type UserFollow = {
	// 被关注用户ID
	followedUserId : number;
	// 关注用户ID
	fansId : number;
}

// 新增用户关注
export const addFollow = (data : UserFollow) => {
	return request({
		url: '/follow/follow',
		method: 'POST',
		data
	})
}

// 删除用户关注
export const delFollow = (data : UserFollow) => {
	return request({
		url: '/follow/follow/delete',
		method: 'DELETE',
		data
	})
}

// 根据用户id获取用户的关注列表
export const getFollowedByFansId = (fansId : number) => {
	return request({
		url: '/follow/follow/fans/' + fansId,
		method: 'GET'
	})
}

// 根据用户id获取用户的粉丝列表
export const getFansByFollowedUserId = (followedUserId : number) => {
	return request({
		url: '/follow/follow/followed/' + followedUserId,
		method: 'GET'
	})
}

export type PanelData = {
	followCount : number;
	fansCount : number;
	postLikeCount : number;
}

// 获取用户关注数、粉丝数、帖子点赞总数
export const getPanelDataForUser = (userId : number) => {
	return request({
		url: '/follow/follow/panel/' + userId,
		method: 'GET'
	})
}